<?php

/**
 * User: yuzy
 */

namespace mybackend\controllers;

use common\services\common\MyscrmOrganizationService;

class OrganizationController extends BaseController {

    protected $_organizationService;

    public function __construct($id, $module, MyscrmOrganizationService $organizationService, $config = []) {
        $this->_organizationService = $organizationService;
        parent::__construct($id, $module, $config);
    }

    /**
     * 获取租户列表（select2控件）
     * @param string $keyword 搜索关键字
     * @param string $page 分页
     */ 
    public function actionGetOrganizationListForSelect2($keyword, $limit) {
        $result = $this->_organizationService->getOrganizationListForSelect2($keyword, $limit);
        $this->exportJson($result, $this->_organizationService->getErrCode(), $this->_organizationService->getErrMsg());
    }
    public function actionGetOrgList(){
        $orgs = $this->_organizationService->getAllOrgs("Id,UniqueName,FriendlyName");
        $errorCode=$this->_organizationService->getErrCode();
        $this->exportJson($orgs, $errorCode?$errorCode:0, $this->_organizationService->getErrMsg());
    }
}
